package info.nixbear.tgcms.services.dao.appengine;

import info.nixbear.tgcms.domain.Website;
import info.nixbear.tgcms.services.dao.DaoException;
import info.nixbear.tgcms.services.dao.WebsiteDao;

import java.util.Arrays;
import java.util.List;

public class AppengineWebsiteDao extends AppengineEntityDao<Website> implements WebsiteDao {

	public AppengineWebsiteDao() {
		super(Website.class);
	}

	@Override
	public Website getDefaultWebsite() throws DaoException {
		List<Website> list = listAll();
		if(!list.isEmpty()) {
			return list.get(0);
		}
		Website website = new Website();
		website.setName("Default");
		website.setUrls(Arrays.asList("default"));
		put(website);
		
		return website;
	}


}
